Skip to content

feat: 更新文件上传前缀支持模板占位符,增强灵活性#2584

Open
sysfox wants to merge 11 commits intomx-space:masterfrom
sysfox:master
Open

feat: 更新文件上传前缀支持模板占位符,增强灵活性#2584
sysfox wants to merge 11 commits intomx-space:masterfrom
sysfox:master

Conversation

@sysfox
Copy link

@sysfox sysfox commented Feb 15, 2026

Description

更新文件上传前缀支持模板占位符,增强灵活性

变量列表
变量 说明 示例输出
{Y} 年份(4位) 2026
{y} 年份(2位) 26
{m} 月份(2位,补零) 02
{d} 日期(2位,补零) 15
{h} 小时(2位,补零) 14
{i} 分钟(2位,补零) 30
{s} 秒钟(2位,补零) 45
{ms} 毫秒(3位,补零) 123
{timestamp} 时间戳(毫秒) 1739620800000
{md5} 随机MD5字符串(32位) 5d41402abc4b2a76b9719d911017c592
{md5-16} 随机MD5字符串(16位) 5d41402abc4b2a76
{uuid} UUID v4字符串 550e8400-e29b-41d4-a716-446655440000
{str-N} 随机字符串,N为长度 {str-10}aBcDeFgHiJ
{filename} 原文件名(包含扩展名) photo.jpg
{name} 原文件名(不含扩展名) photo
{ext} 文件扩展名(包含点号) .jpg
{type} 文件类型 image / file / avatar / icon
{localFolder:N} 原文件所在文件夹(N为层级数) {localFolder:1}uploads

配置示例:
image

结果测试:
image

Linked Issues

#2469

Additional context

Copilot AI review requested due to automatic review settings February 15, 2026 14:43
@safedep
Copy link

safedep bot commented Feb 15, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@gitguardian
Copy link

gitguardian bot commented Feb 15, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
26382684 Triggered Username Password b89c707 apps/core/src/constants/error-code.constant.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for template placeholders in file upload paths and filenames, addressing issue #2469. The feature allows users to customize file naming and organization using dynamic placeholders like date/time, random strings, MD5 hashes, and UUIDs. Additionally, the PR improves S3 compatibility for Tencent COS by implementing virtual-hosted style URLs and adds a new security scanning workflow.

Changes:

  • Added a comprehensive filename template utility with 16+ placeholder types for flexible file organization
  • Implemented new file upload configuration options with customizable naming and path templates
  • Enhanced S3 uploader to support Tencent COS virtual-hosted style endpoints and improved error messages

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
apps/core/src/utils/filename-template.util.ts New utility implementing template placeholder replacement system for filenames and paths
apps/core/test/src/utils/filename-template.util.spec.ts Comprehensive test suite for template functionality covering all placeholders
apps/core/src/modules/configs/configs.schema.ts Added FileUploadOptions schema with template configuration fields
apps/core/src/modules/configs/configs.interface.ts Extended IConfig interface to include fileUploadOptions
apps/core/src/modules/configs/configs.default.ts Added default configuration for file upload options
apps/core/src/modules/file/file.controller.ts Integrated template system into file upload endpoint with path construction logic
apps/core/src/processors/helper/helper.image-migration.service.ts Applied template processing to S3 prefix for image migration
apps/core/src/utils/s3.util.ts Added Tencent COS virtual-hosted style support and enhanced error reporting
.github/workflows/strix.yml Added new security scanning workflow using Strix tool

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sysfox and others added 2 commits February 15, 2026 22:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Teror Fox <imaginehtr@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant